<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>大梁造植物识别项目</title>
    <link rel="stylesheet" th:href="@{~/css/base.css}">
</head>
<body>
<h1>大梁造植物识别项目</h1>
<form id="form1" action="/index" method="POST" enctype="multipart/form-data">
    <input id="upload" type="file" name="file">
    <input type="button" value="上传" onclick="getSubmit();">
</form>
<div th:if="${maxResult!=null}">
    <div class="result">
        <ul th:each="Info: ${plantInfo.result}">
            <li th:text="'花名: '+${Info.name}"></li>
            <li th:text="'近似度: '+${Info.score}"></li>
        </ul>
    </div>
    <div class="maxResult">
        <span>最佳适配结果：</span>
        <span th:text="${maxResult}"></span>
    </div>
</div>
<script>
    function getSubmit() {
        var file = document.getElementById("upload").value;
        if (!file) {
            alert('您还没有选择文件！');
            return;
        } else {
            document.getElementById("form1").submit();
        }
    }
</script>
</body>
</html>